home *** CD-ROM | disk | FTP | other *** search
/ PC go! 2018 July / PCgo 07-2018 CD-ROM Germany.iso / nw.pak / Unnamed File 000198.txt < prev    next >
Encoding:
Text File  |  2015-07-29  |  2.2 KB  |  95 lines

  1.  
  2.  
  3.   (function() {
  4.  
  5.     var p = {
  6.  
  7.       eventDelegates: {
  8.         down: 'downAction'
  9.       },
  10.  
  11.       activeChanged: function() {
  12.         this.super();
  13.  
  14.         if (this.$.ripple) {
  15.           if (this.active) {
  16.             // FIXME: remove when paper-ripple can have a default 'down' state.
  17.             if (!this.lastEvent) {
  18.               var rect = this.getBoundingClientRect();
  19.               this.lastEvent = {
  20.                 x: rect.left + rect.width / 2,
  21.                 y: rect.top + rect.height / 2
  22.               }
  23.             }
  24.             this.$.ripple.downAction(this.lastEvent);
  25.           } else {
  26.             this.$.ripple.upAction();
  27.           }
  28.         }
  29.  
  30.         this.adjustZ();
  31.       },
  32.  
  33.       disabledChanged: function() {
  34.         this._disabledChanged();
  35.         this.adjustZ();
  36.       },
  37.  
  38.       recenteringTouchChanged: function() {
  39.         if (this.$.ripple) {
  40.           this.$.ripple.classList.toggle('recenteringTouch', this.recenteringTouch);
  41.         }
  42.       },
  43.  
  44.       fillChanged: function() {
  45.         if (this.$.ripple) {
  46.           this.$.ripple.classList.toggle('fill', this.fill);
  47.         }
  48.       },
  49.  
  50.       adjustZ: function() {
  51.         if (!this.$.shadow) {
  52.           return;
  53.         }
  54.         if (this.active) {
  55.           this.$.shadow.setZ(2);
  56.         } else if (this.disabled) {
  57.           this.$.shadow.setZ(0);
  58.         } else {
  59.           this.$.shadow.setZ(1);
  60.         }
  61.       },
  62.  
  63.       downAction: function(e) {
  64.         this._downAction();
  65.  
  66.         if (this.hasAttribute('noink')) {
  67.           return;
  68.         }
  69.  
  70.         this.lastEvent = e;
  71.         if (!this.$.ripple) {
  72.           var ripple = document.createElement('paper-ripple');
  73.           ripple.setAttribute('id', 'ripple');
  74.           ripple.setAttribute('fit', '');
  75.           if (this.recenteringTouch) {
  76.             ripple.classList.add('recenteringTouch');
  77.           }
  78.           if (!this.fill) {
  79.             ripple.classList.add('circle');
  80.           }
  81.           this.$.ripple = ripple;
  82.           this.shadowRoot.insertBefore(ripple, this.shadowRoot.firstChild);
  83.           // No need to forward the event to the ripple because the ripple
  84.           // is triggered in activeChanged
  85.         }
  86.       }
  87.  
  88.     };
  89.  
  90.     Polymer.mixin2(p, Polymer.CoreFocusable);
  91.     Polymer('paper-button-base',p);
  92.  
  93.   })();
  94.  
  95.